import java.util.HashSet;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        HashBucket hashBucket = new HashBucket();
        hashBucket.put(1, 1);
        hashBucket.put(3, 3);
        hashBucket.put(13, 3);
        hashBucket.put(5, 5);
        hashBucket.put(6, 6);
        hashBucket.put(8, 8);
        hashBucket.put(33, 3);
        hashBucket.put(2, 2);
        hashBucket.put(12, 12);
        hashBucket.put(4, 4);
        hashBucket.put(17, 7);
        System.out.println("============");
        System.out.println(hashBucket.get(33));
        System.out.println(hashBucket.get(17));
    }

    public int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])) {
                set.remove(nums[i]);
            } else {
                set.add(nums[i]);
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])) {
                return nums[i];
            }
        }
        return -1;
    }

    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        char[] arr1 = jewels.toCharArray();
        char[] arr2 = stones.toCharArray();
        int count = 0;
        for (int i = 0; i < arr1.length; i++) {
            set.add(arr1[i]);
        }
        for (int i = 0; i < arr2.length; i++) {
            if (set.contains(arr2[i])) {
                count++;
            }
        }
        return count;
    }
}
